package cn.i7baozh.provider.hystrix.controller;

import cn.i7baozh.provider.hystrix.service.PaymentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

/**
 * @Title:
 * @Description:
 * @author: baoqi.zhang
 * @date: 2022/4/9 20:56
 */
@Slf4j
@RestController
public class OrderController {

    @Autowired
    private PaymentService paymentService;

    @Value("server.port")
    private String port;

    @GetMapping("provider/hystrix/ok/{id}")
    public String paymentInfoOk(@PathVariable("id") Integer id) {
        String result = paymentService.paymentInfoOk(id);
        log.info("ok:{}", result);
        return result;
    }

    @GetMapping("provider/hystrix/error/{id}")
    public String paymentInfoError(@PathVariable("id")Integer id) {
        String result = paymentService.paymentInfoError(id);
        log.info("error:{}", result);
        return result;
    }
    @GetMapping("provider/hystrix/breaker/{id}")
    public String paymentInfoCircuitBreak(@PathVariable("id")Integer id) {
        String result = paymentService.paymentCircuitBreaker(id);
        log.info("paymentInfoCircuitBreak:{}", result);
        return result;
    }
}
